package com.sasken.pdb.views.renderers
{
	import com.sasken.pdb.models.data.ProjectResource;
	import com.sasken.pdb.models.settings.ApplicationSettings;
	
	import flash.events.Event;
	
	import mx.controls.DateField;
	import mx.core.IDataRenderer;

	/**
	 *  An editor renderer which allows editing dates through a standard DateField interface. 
	 */ 
	public class DateEditorRenderer extends DateField implements IDataRenderer
	{
		public function DateEditorRenderer()
		{
			super();
			
			opaqueBackground = 0xffffff;
			formatString = ApplicationSettings.DATE_FORMAT;
			addEventListener(Event.CHANGE, changeListener);
		}
		
		private function changeListener(e:Event):void
		{
			//data = selectedDate;
		}
		public override function set data(value:Object):void
		{
			super.data = value;
			
			if (value is ProjectResource)
			{
				selectedDate = (value as ProjectResource).startDate;
			}
			
		}
		
		
	}
}